# -*- coding: utf-8 -*-
import scrapy
from XiaChuFang.items import advertItem

class AdvertSpider(scrapy.Spider):
    name = 'advert'
    allowed_domains = ['xiachufang.com']
    start_urls = ['http://www.xiachufang.com/']

    def parse(self, response):
        heads = response.xpath("//div[@class='unslider headline-slider']/ul/li")

        for head in heads:
             item = advertItem()
             # 标题
             item['title'] = head.xpath("./a[2]/text()").extract()[0]
             # 图片地址
             item['image'] = head.xpath("./a[1]/img/attribute::src").extract()[0]

             yield item